﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ASPNETVN.PORTAL.Components.UI;
using System.Collections;
using ASPNETVN.PORTAL.Components.Configuration.Settings;
using ASPNETVN.PORTAL.Components.UI.DataTypes;
using ASPNETVN.PORTAL.Components.Helpers;

namespace CDTM.Modules.TraCuuDiem
{
    public enum ModulePages
    {
        DiemTuyenSinh,
        DiemTotNghiep,
        KetQuaHocTap,
        KetQuaRenLuyen,
        ViewMenu
    }

    public partial class Main : PortalModuleControl
    {
        public Main()
        {
            // Define an Array List
            ArrayList list = new ArrayList();
            // Hai cột hai bên, bên trái 01 tin có hình minh hoạt width: 250px
            // Tham khảo http://lienchieu.danang.gov.vn
            list.Add(new ListItem("ViewMenu", "ViewMenu"));
            list.Add(new ListItem("DiemTuyenSinh", "DiemTuyenSinh"));
            list.Add(new ListItem("DiemTotNghiep", "DiemTotNghiep"));
            list.Add(new ListItem("KetQuaHocTap", "KetQuaHocTap"));
            list.Add(new ListItem("KetQuaRenLuyen", "KetQuaRenLuyen"));
            ModuleSettingItem itemSetting = new ModuleSettingItem(new CustomListDataType(list, "Text", "Value"));
            itemSetting.Value = "ViewMenu";
            itemSetting.Name = "Hình thức hiển thị nội dung o trang tra cuu diem";
            itemSetting.Description = "Hình thức hiển thị nội dung ở trang tra cuu diem";
            itemSetting.SortOrder = 1;
            this.BaseSettings.Add("DisplayStyle", itemSetting);


            // Define an Array List
            ArrayList list1 = new ArrayList();

            // Sắp xếp theo cột.
            list1.Add(new ListItem("Top 3 records", "3"));
            list1.Add(new ListItem("Top 5 records", "5"));
            list1.Add(new ListItem("Top 10 records", "10"));
            list1.Add(new ListItem("Top 20 records", "20"));

            itemSetting = new ModuleSettingItem(new CustomListDataType(list1, "Text", "Value"));
            itemSetting.Name = "Top records";
            itemSetting.Value = "10";
            itemSetting.Description = "Top records";
            itemSetting.SortOrder = 1;
            this.BaseSettings.Add("TopRecords", itemSetting);
        }

        private void LoadChildControl()
        {
            const string basePath = "~/Modules/CDTM.Modules.TraCuuDiem/";
            ModulePages page = (ModulePages)Enum.Parse(typeof(ModulePages), this.Settings["DisplayStyle"].ToString(), true);
            string src = string.Format("{0}Controls/{1}.ascx", basePath, page);
            ModulePage ctl = (ModulePage)this.LoadControl(src);
            ctl.ParentControl = this;
            ContentPane.Controls.Add(ctl);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.LoadChildControl();
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            //this.ModuleTitle.AddUrl = HttpUrlBuilder.BuildAddEditUrl(this.ModuleID, 0, "AddEditItem");
            this.ModuleTitle.ManagerUrl = HttpUrlBuilder.BuildAddEditUrl(this.ModuleID, 0, "ItemManager");
        }
    }
}